﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HMS.BL;
using HMS.Common;
using HMS.DL;
using System.Web.Script.Serialization;

namespace HMS.PL.Forms
{
    public partial class MasterCallback : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {

                string strOpern = String.IsNullOrEmpty(Request.QueryString["operation"]) ? "" : Request.QueryString["operation"].ToString();

                if (strOpern == null || strOpern == "")
                {
                    strOpern = Request.Form["oper"];
                }

                MasterData objMasterData = new MasterData();
                if (String.IsNullOrEmpty(Request.QueryString["reconstruct"]) == false)
                {
                    return;
                }

                switch (strOpern)
                {

                    case "bind_master":
                        Response.Write(objMasterData.GetMaster());
                        break;
                    case "bind_fields":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt32(Request.QueryString["id"].ToString());
                        Response.Write(objMasterData.GetFields());
                        break;
                    case "get_gridColdata":                        
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.bShowDetailLink =String.IsNullOrEmpty(Request.Params["blink"]) ? false : Convert.ToBoolean(Request.QueryString["blink"]);  
                        Response.Write(objMasterData.GetGridColdata());
                        break;
                    case "get_griddata":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        Response.Write(objMasterData.GetGriddata());
                        break;
                    case "del":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.id = String.IsNullOrEmpty(Request.Form["_id"]) ? 0 : Convert.ToInt32(Request.Form["_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        Response.Write(objMasterData.DelData());
                        break;
                    case "edit":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.id = String.IsNullOrEmpty(Request.Form["_id"]) ? 0 : Convert.ToInt32(Request.Form["_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.allkeys = Request.Form;
                        Response.Write(objMasterData.EditData());
                        break;
                    case "add":  
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.allkeys = Request.Form;
                        Response.Write(objMasterData.AddData());
                        break;
                    case "select_dim":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.MasterId = String.IsNullOrEmpty(Request.QueryString["mast_id"]) ? 0 : Convert.ToInt32(Request.QueryString["mast_id"].ToString());
                        Response.Write(objMasterData.GetMasterData());
                        break;
                    //not being used
                    //case "get_coldataURL":
                    //    //test method for jqgrid url
                    //    objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                    //    objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                    //    Response.Write(objMasterData.GetGriddataURL(false));
                    //    break;

                    //case "get_griddataURL":
                    //    //test method for jqgrid url
                    //    objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                    //    objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                    //    objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                    //    objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "asc" : Convert.ToString(Request.Params["sord"].ToString());
                    //    objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                    //    objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                    //    Response.Write(objMasterData.GetGriddataURL(true));
                    //    break;

                    case "change_source": //done
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.MasterId = String.IsNullOrEmpty(Request.QueryString["mast_id"]) ? 0 : Convert.ToInt32(Request.QueryString["mast_id"].ToString());
                        objMasterData.srcVal = Request.QueryString["chgVal"].ToString();
                        Response.Write(objMasterData.SaveChangedSource());
                        break;

                    case "ImportData":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.strfileName = Request.QueryString["filename"].ToString();//filename
                        objMasterData.strfilePath = Server.MapPath("..\\Excel") + "\\" + Request.QueryString["filename"].ToString();
                        objMasterData.strSheetName = Request.QueryString["sheetname"].ToString();
                        Response.Write(objMasterData.ImportData());
                        break;
                    case "get_gridColdataMatchRule":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Convert.ToDouble(Request.QueryString["list_id"].ToString()));
                        Response.Write(objMasterData.GetMatchRuleColumns(true));
                        break;
                    case "get_gridColdataMatchRuleImp":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Convert.ToDouble(Request.QueryString["list_id"].ToString()));
                        Response.Write(objMasterData.GetMatchRuleColumns(false));
                        break;
                    case "get_griddataMatchRule":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.QueryString["rule_id"]) ? 1 : Convert.ToInt32(Request.QueryString["rule_id"].ToString());
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.GetMatchRuledata());
                        break;
                    case "get_griddataManualRule":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.QueryString["rule_id"]) ? 1 : Convert.ToInt32(Request.QueryString["rule_id"].ToString());
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.GetManualRuledata());
                        break;
                    //case "get_griddataSubGrid":
                    //    objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                    //    objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                    //    objMasterData.MASTER_ID = 1;
                    //    objMasterData.MASTER_ID = String.IsNullOrEmpty(Request.QueryString["MASTER_ID"]) ? 0 : Convert.ToDecimal(Request.QueryString["MASTER_ID"].ToString());
                    //    // objMasterData.MASTER_ID = String.IsNullOrEmpty(Request.QueryString["MANUAL_RULE_ID"]) ? 0 : Convert.ToDecimal(Request.QueryString["MANUAL_RULE_ID"].ToString());
                    //    //MANUAL_RULE_ID
                    //    //Response.Write(objMasterData.GetSubGriddata());
                    //    break;

                    case "matchRule": 
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.matchRule());
                        break;
                    case "get_griddataUnMatchRule":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.GetUnMatchRuledata());
                        break;
                    case "get_griddataImport":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.GetImportdata());
                        break;
                    case "MatchApply":
                        //test method for jqgrid url
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.Params["rule_id"]) ? 1 : Convert.ToInt32(Request.Params["rule_id"].ToString());
                        objMasterData.Ids = String.IsNullOrEmpty(Request.Params["Ids"]) ? "" : Convert.ToString(Request.Params["Ids"].ToString());
                        JavaScriptSerializer js = new JavaScriptSerializer();
                        objMasterData.LstIds = js.Deserialize<List<LstIds>>(Request.Params["jsonstring"]);
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.saveMatchData());
                        break;
                    case "manualMatchApply":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.Params["rule_id"]) ? 1 : Convert.ToInt32(Request.Params["rule_id"].ToString());
                        JavaScriptSerializer js1 = new JavaScriptSerializer();
                        objMasterData.LstManualIds = js1.Deserialize<List<LstManualIds>>(Request.Params["jsonstring"]);
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.saveManualMatchData());
                        break;
                    case "UnmatchApply":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        // objMasterData.RuleId = String.IsNullOrEmpty(Request.Params["rule_id"]) ? 1 : Convert.ToInt32(Request.Params["rule_id"].ToString());
                        JavaScriptSerializer jsU = new JavaScriptSerializer();
                        objMasterData.LstIds = jsU.Deserialize<List<LstIds>>(Request.Params["jsonstring"]);
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.saveUnMatchData());
                        break;
                    case "MatchSendtoUnMatch":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.Params["rule_id"]) ? 1 : Convert.ToInt32(Request.Params["rule_id"].ToString());
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.MatchSendtoUnMatch());
                        break;
                    case "ManualSendtoUnMatch":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        objMasterData.RuleId = String.IsNullOrEmpty(Request.Params["rule_id"]) ? 1 : Convert.ToInt32(Request.Params["rule_id"].ToString());
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.ManualSendtoUnMatch());
                        break;
                    case "fillExistProcGrid":
                        Response.Write(objMasterData.fillExistProcGrid());
                        break;
                    case "fillExistProcGridData":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        Response.Write(objMasterData.fillExistProcGridData());
                        break;
                    case "discard":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.Params["list_id"]) ? 0 : Convert.ToInt32(Request.Params["list_id"].ToString());
                        objMasterData.dimTableName = Request.Params["dimtable_name"].ToString();
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.Params["imp_id"]) ? 0 : Convert.ToInt32(Request.Params["imp_id"].ToString());
                        Response.Write(objMasterData.discard());
                        break;
                    case "showExistProc":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt32(Request.QueryString["list_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.Imp_Id = String.IsNullOrEmpty(Request.QueryString["imp_id"]) ? 0 : Convert.ToInt32(Request.QueryString["imp_id"].ToString());
                        Response.Write(objMasterData.ShowExistProc());
                        break;
                    case "ImportDataRel":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["Mlist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Mlist_id"].ToString());
                        objMasterData.ChildListId = String.IsNullOrEmpty(Request.QueryString["Clist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Clist_id"].ToString());
                        //objMasterData.dimTableName = Request.QueryString["Mdimtable_name"].ToString();
                        //objMasterData.ChilddimTableName = Request.QueryString["Cdimtable_name"].ToString();
                        objMasterData.strfileName = Request.QueryString["filename"].ToString();//filename
                        objMasterData.strfilePath = Server.MapPath("..\\Excel") + "\\" + Request.QueryString["filename"].ToString();
                        objMasterData.strSheetName = Request.QueryString["sheetname"].ToString();
                        Response.Write(objMasterData.ImportDataRel());
                        break;
                    case "GetRelData":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["Mlist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Mlist_id"].ToString());
                        objMasterData.ChildListId = String.IsNullOrEmpty(Request.QueryString["Clist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Clist_id"].ToString());
                        objMasterData.dimTableName = Request.QueryString["dimtable_name"].ToString();
                        objMasterData.MasterId = String.IsNullOrEmpty(Request.QueryString["mast_id"]) ? 0 : Convert.ToInt32(Request.QueryString["mast_id"].ToString());
                        objMasterData.sidx = String.IsNullOrEmpty(Request.Params["sidx"]) ? "" : Convert.ToString(Request.Params["sidx"].ToString());
                        objMasterData.sord = String.IsNullOrEmpty(Request.Params["sord"]) ? "desc" : Convert.ToString(Request.Params["sord"].ToString());
                        objMasterData.rows = String.IsNullOrEmpty(Request.Params["rows"]) ? 10 : Convert.ToInt32(Request.Params["rows"].ToString());
                        objMasterData.page = String.IsNullOrEmpty(Request.Params["page"]) ? 1 : Convert.ToInt32(Request.Params["page"].ToString());
                        objMasterData._search = String.IsNullOrEmpty(Request.Params["_search"]) ? false : Convert.ToBoolean(Request.Params["_search"]);
                        objMasterData.query = String.IsNullOrEmpty(Request.Params["searchQuery"]) ? "" : Convert.ToString(Request.Params["searchQuery"]);
                        Response.Write(objMasterData.GetMasterRelData());
                        break;
                    case "GetRelDataGraph":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["Mlist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Mlist_id"].ToString());
                        objMasterData.arrMastId= Request.QueryString["Ids"].Split(',');
                        Response.Write(objMasterData.GetMasterRelDataGraph());
                        break;
                    case "GetRelDataChildGraph":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["Mlist_id"]) ? 0 : Convert.ToInt32(Request.QueryString["Mlist_id"].ToString());
                        objMasterData.ParentId = String.IsNullOrEmpty(Request.QueryString["parentid"]) ? 0 : Convert.ToInt64(Request.QueryString["parentid"]);
                        Response.Write(objMasterData.GetRelDataChildGraph());
                        break;
                    case "GetRelDataDetail":
                        objMasterData.ListId = String.IsNullOrEmpty(Request.QueryString["list_id"]) ? 0 : Convert.ToInt64(Request.QueryString["list_id"].ToString());
                        objMasterData.MasterId = String.IsNullOrEmpty(Request.QueryString["id"]) ? 0 : Convert.ToInt64(Request.QueryString["id"].ToString());
                        //objMasterData.ParentId = String.IsNullOrEmpty(Request.QueryString["parent_id"]) ? 0 : Convert.ToInt64(Request.QueryString["parent_id"].ToString());
                        objMasterData.ParentIds = String.IsNullOrEmpty(Request.QueryString["parent_id"]) ? "" : Convert.ToString(Request.QueryString["parent_id"].ToString());
                        Response.Write(objMasterData.GetRelDataDetail());
                        break;
                    default:
                        Response.Write(objMasterData.GetMaster());
                        break;
                }
            }
        }
    }
}